package com.example.family_sec;

import okhttp3.Callback;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;

public class NetUtil {
    public static final String IPV4 = "192.168.1.104";

    public static final String HOST = "http://"+IPV4+":8888";

    // 用户登录
    public static void login(String url, IUser user, Callback callback)  {




        OkHttpClient okHttpClient = new OkHttpClient();

        RequestBody body = new MultipartBody.Builder()
                .setType(MultipartBody.FORM)


                // key 名字
                /**
                 *  name key
                 *  file.getName 文件名包括后缀
                 *  fileBody 文件内容选择, 上传
                 */
                .addFormDataPart("phone", user.getPhone())
                .addFormDataPart("password",user.getPassWord())

                .build();
        Request request = new Request.Builder().post(body).url(url).addHeader("whoareu","family").build();
        okHttpClient.newCall(request).enqueue(callback);
    }

    public static void pickPass(String url,Callback callback) {

        OkHttpClient okHttpClient = new OkHttpClient();

        Request request = new Request.Builder().url(url).get().addHeader("whoareu","family").build();

        okHttpClient.newCall(request).enqueue(callback);
    }
}
